import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsString, IsNumber, IsBoolean, IsNotEmpty } from 'class-validator';
import { prop, getModelForClass } from '@typegoose/typegoose';

/**
 * 邮件配置模型
 * 用于存储系统邮件发送相关的配置信息
 */
export class EmailConfig {
  @ApiProperty({ description: '邮件显示名称', example: 'smtp.qq.com' })
  @IsNotEmpty()
  @IsString()
  @prop()
  emailName: string

  @ApiProperty({ description: '邮件服务器主机地址', example: 'smtp.qq.com' })
  @IsOptional()
  @IsString()
  @prop()
  emailHost?: string;

  @ApiProperty({ description: '邮件服务器端口', example: 587 })
  @IsOptional()
  @IsNumber()
  @prop()
  emailPort?: number;

  @ApiProperty({ description: '邮件服务器是否使用安全连接', example: false })
  @IsOptional()
  @IsBoolean()
  @prop({ default: false })
  emailSecure?: boolean;

  @ApiProperty({ description: '邮件服务器用户名', example: 'user@example.com' })
  @IsOptional()
  @IsString()
  @prop()
  emailUser?: string;

  @ApiProperty({ description: '邮件服务器密码' })
  @IsOptional()
  @IsString()
  @prop()
  emailPassword?: string;

  @ApiProperty({ description: '收件人邮箱地址', example: 'admin@example.com' })
  @IsOptional()
  @IsString()
  @prop()
  emailToAddress?: string;

  @ApiProperty({ description: '收件人邮箱名称', example: '管理员' })
  @IsOptional()
  @IsString()
  @prop()
  emailToName?: string;

  @ApiProperty({ description: '是否启用此配置', example: true })
  @IsOptional()
  @IsBoolean()
  @prop({ default: true })
  isActive?: boolean;

  @ApiProperty({ description: '创建时间' })
  @prop({ default: Date.now })
  createdAt?: Date;

  @ApiProperty({ description: '更新时间' })
  @prop({ default: Date.now })
  updatedAt?: Date;
}